import time
import re

from public.action import *
from public.business import *
from public.testData import *
from public.tools import*

testCase="DBshop041_客户管理删除客户余额充值记录"
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,"客户管理","客户余额","充值记录")
#在被充值人输入框中输入用户名
firefox.find_element_by_name("user_name").send_keys(userName)
#点击搜索按钮
firefox.find_element_by_xpath("//button[@type='submit']").click()

#1.点击“删除”按钮，确定删除，删除成功。
#点击用户名对应的删除超链接
firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[5]/a"%userName).click()
#确认弹窗
firefox.switch_to.alert.accept()
time.sleep(1)
#断言
try:
    if firefox.find_element_by_xpath("//td[text()='%s']"%userName).is_displayed():#如果用户名显示
        writeLog("%s 测试失败" % testCase)
        getPhoto(firefox)
except:
    writeLog("%s 测试通过" % testCase)
firefox.quit()
